Page({

  /**
   * 页面的初始数据
   */
  data: {
    image_url:'',//图片
    name:'',  //名字
    alias_name:'',  //别名
    latin_name:'',  //拉丁名
    catalog_name:'',   //类别名
    abstract_text: '',   //摘要，2500字以内
    keys: '',             //关键字（如药食同源，有毒，无毒)
    keys_script: '',        //关键字的进一步描述，比如：哪个部位能吃
    cn_medica_script: '',    // 中医药理描述
    content: '' ,             //详细说明
    area_names:''    ,      //地区名
    contentDecode:1   //是否解码
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that=this;
    var test;
    test=wx.getStorageSync('returnData');
    console.log('test' + test);
    if (test =='null')
    {
      that.setData({ name: '暂无数据'  });
      that.setData({ alias_name: '暂无数据'  });
      that.setData({ latin_name: '暂无数据'  });
      that.setData({ catalog_name: '暂无数据'  });
      that.setData({ abstract_text: '暂无数据' });
      that.setData({ keys: '暂无数据' });
      that.setData({ keys_script: '暂无数据' });
      that.setData({ cn_medica_script: '暂无数据' });
      that.setData({ content: '暂无数据' });
    }else{
      that.setData({ name: test.name });
      that.setData({ alias_name: test.alias_name == 'null' ? '暂无数据' : test.alias_name });
      that.setData({ latin_name: test.latin_name == null ? "暂无数据" : test.latin_name });
      that.setData({ catalog_name: test.catalog_name });
      that.setData({ abstract_text: test.abstrac == null ? "暂无数据" : test.abstrac });
      that.setData({ keys: test.keys == null ? '暂无数据' : test.keys });
      that.setData({ keys_script: test.keys_script == null ? "暂无数据" : test.keys_script });
      that.setData({ cn_medica_script: test.cn_medica_script == null ? "暂无数据" : test.cn_medica_script });
      var content = test.content;
      //使用正则替换，使用replace只能替换第一个
      content = content.replace(/<p>/g, "&emsp;&emsp;");
      content = content.replace(/<\/p>/g, '\n');
      console.log(content);
      that.setData({ content: content });
      that.setData({ area_names: test.area_names == 'null' ? '暂无数据' : test.area_names })
    }
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
    
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
    
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
    
  }
})